package com.banyuan.lesson.输入输出流;

import java.io.FileInputStream;
import java.io.IOException;

/*
 * 文件字节输入流；
 * 字节数组构造字节输入流；
 * 一些常用的方法；
 * */
public class TestFIleInputStream1 {
    public static void main(String[] args) {
        try (FileInputStream in = new FileInputStream("aaa.txt")) {
            byte[] buf = new byte[8];
            //跳过两个字节；
            in.skip(2);
            //显示还剩多少个字节；
            int i = in.available();
            System.out.println(i);
            //n表示实际读取的字节数；
            int n = in.read(buf);
            System.out.println(new String(buf));
            System.out.println(n);
            //是否支持标记；
            System.out.println(in.markSupported());
            //标记和重置；
            in.mark(2);
            in.reset();

            n = in.read(buf);
            System.out.println(new String(buf));
            System.out.println(n);

            buf = new byte[8];
            n = in.read(buf);
            System.out.println(new String(buf));

        } catch (IOException e) {
            e.printStackTrace();
        }

    }

}
